/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pv168.uloha3.managers;

import cz.muni.fi.pv168.uloha3.entities.Owner;
import cz.muni.fi.pv168.uloha3.entities.Ownership;
import cz.muni.fi.pv168.uloha3.entities.RealEstate;
import cz.muni.fi.pv168.uloha3.exceptions.OwnershipManagerException;
import java.util.Set;
import javax.sql.DataSource;

/**
 *
 * @author stefan
 */
public interface OwnershipManager {
    
    /**
     * 
     * @param ownership Ownership to be created
     * @throws IllegalArgumentException if provided {@code ownership} is null
     */
    public void createOwnerwhip(Ownership ownership) throws IllegalArgumentException, OwnershipManagerException;
    
    /**
     * 
     * @param ownership Ownership to be updated
     * @throws IllegalArgumentException if {@code ownership} was null
     * @throws OwnershipManagerException if no such {@link Ownership} exists
     */
    public void updateOwnership(Ownership ownership) throws IllegalArgumentException, OwnershipManagerException;
    
    /**
     * 
     * @param ownership Ownership to be deleted
     * @throws IllegalArgumentException if {@code ownership} was null
     * @throws OwnershipManagerException if {@link Ownership} was already ended, 
     * if it is the single (/last active) {@link Ownership} on that {@link RealEstate} or if no such {@link Ownership} exists
     */
    public void endOwnership(Ownership ownership) throws IllegalArgumentException, OwnershipManagerException;
    
    /**
     * 
     * @return {@code Set} of all {@link Ownership}s
     */
    public Set<Ownership> getOwnerships() throws IllegalArgumentException, OwnershipManagerException;
    
    /**
     * 
     * @param realEstate
     * @return {@code Set} of all {@link Ownership}s on the provided {@code realEstate}
     */
    public Set<Ownership> getOwnershipsByRealEstate(RealEstate realEstate) throws IllegalArgumentException, OwnershipManagerException;
    
    /**
     * 
     * @param owner
     * @return {@code Set} of all the {@link Ownership}s of the provided {@code owner}
     */
    public Set<Ownership> getOwnershipsByOwner(Owner owner) throws IllegalArgumentException, OwnershipManagerException;
    
    /**
     * 
     * @param id Id of the Ownership to return, 
     * @return Ownership with provided id, null if no {@link Ownership} with that id exists
     * @throws OwnershipManagerException if {@link Ownership} with provided id ended
     * @throws IllegalArgumentException if {@code id} was null
     */
    public Ownership getOwnershipById(Long id) throws IllegalArgumentException, OwnershipManagerException;
    
    public void setDataSource(DataSource datasource);

    public void setOwnerManager(OwnerManager ownerManager);

    public void setRealEstateManager(RealEstateManager realEstateManager);
}
